import { sp } from "cc";
import { CCInteger } from "cc";
import { _decorator, Sprite } from "cc";

const { ccclass, property } = _decorator;
/**
 * 放多个骨骼，用dataIdx切换
 */
@ccclass("MySkeleton")
export class MySkeleton extends sp.Skeleton {
    @property
    private _dataList: sp.SkeletonData[] = [];
    @property(CCInteger)
    private _dataIdx = -1;

    @property(CCInteger)
    public set dataIdx(value: number) {
        this._dataIdx = value;
        this.skeletonData = this._dataList[value];
    }
    public get dataIdx() {
        return this._dataIdx;
    }
    @property([sp.SkeletonData])
    public set dataList(value: sp.SkeletonData[]) {
        this._dataList = value;
        this._dataIdx = this.dataIdx;
    }
    public get dataList() {
        return this._dataList;
    }
}